#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>
	il void read(T &x){
		int f=1;x=0;char c=gc();
		while(c<'0'||c>'9'){
			if(c=='-'){
				f=-1;
			}
			c=gc();
		}
		while(c>='0'&&c<='9'){
			x=x*10+c-48,c=gc();
		}
		x*=f;
	}
	template<typename T,typename ...Args>
	void read(T &x,Args &...args){
		read(x),read(args...);
	}
	template<typename T>
	il void write(T x){
		char buf[43];int len=0;
		if(x<0){
			pc('-'),x=-x;
		}
		do{
			buf[++len]=x%10,x/=10;
		}while(x);
		while(len){
			pc(buf[len--]+'0');
		}
	}
}
using namespace my_std;
const int N=1e5+7,M=-1,inf=0x3f3f3f3f,mod=0;
const ll INF=1ll*inf*inf;
int n,m,rt,A,B;
int tot,head[N];
struct ndoe{
	int to,nxt;
}e[N<<1];
il void add(int u,int v){
	e[++tot]={v,head[u]},head[u]=tot;
}
namespace s1{
	const int N=3e3+7;
	int fa[N],mxd[N],dp[N][2],f[N],g[N][N],mn[N][N];
	bool FL=0;
	void dfs2(int u,int dep){
		if(!dep){
			f[u]=g[u][B];
			return;
		}
		f[u]=0;
		int a=inf,b=inf,c=-inf,d=-inf,C=inf,D=inf,k=0,cnt=0;
		go(i,u){
			int v=e[i].to;
			if(v==fa[u]){
				continue;
			}
			// if(FL){
				// printf("--%d %d\n",u,v);
			// }
			k++,cnt+=mxd[v]>=A-1;
			dfs2(v,dep-1);
			if(dep+1<=B){
				int t=g[v][B-dep-1];
				if(t<a){
					b=a,a=t;
				}else if(t<b){
					b=t;
				}
			}
			if(dep<=B){
				int t=dp[v][1];
				if(t>c){
					d=c,c=t;
				}else if(t>d){
					d=t;
				}
				// if(mxd[v]<A-1){
					t=mn[v][B-1];
					if(t<C){
						D=C,C=t;
					}else if(t<D){
						D=t;
					}
				// }
			}
		}
		if(!k){
			f[u]=-inf;
			return;
		}
		go(i,u){
			int v=e[i].to;
			if(v==fa[u]){
				continue;
			}
			int t=f[v];
			if(dep+1<=B){
				t=min(t,g[v][B-dep-1]==a?b:a);
			}
			if(dep<=B){
				if(!cnt-(mxd[v]>=A-1)){
					t=min(t,min(u,mn[v][B-1]==C?D:C));
					// if(FL){
						// printf("%d %d %d\n",u,t,f[u]);
						// puts("!111112");
					// }
				}else{
					t=min(t,dp[v][1]==c?d:c);
				}
			}
			if(FL){
				printf("%d %d %d %d\n",u,v,t,f[v]);
			}
			f[u]=max(f[u],t);
		}
		if(FL){
			printf("%d %d\n",u,f[u]);
			go(i,89){
				printf("++%d\n",e[i].to);
			}
		}
	}
	void dfs1(int u){
		go(i,u){
			int v=e[i].to;
			if(v==fa[u]){
				continue;
			}
			fa[v]=u,dfs1(v);
			mxd[u]=max(mxd[u],mxd[v]+1);
			rep(j,1,B){
				g[u][j]=min(g[u][j],g[v][j-1]);
				mn[u][j]=min(mn[u][j],mn[v][j-1]);
			}
		}
		rep(i,0,B){
			mn[u][i]=min(mn[u][i],u);
		}
		if(mxd[u]<A){
			dp[u][0]=mn[u][B];
		}else{
			dfs2(u,A),dp[u][0]=f[u];
		}
		if(mxd[u]<A-1){
			dp[u][1]=min(fa[u],mn[u][B-1]);
		}else{
			dfs2(u,A-1),dp[u][1]=f[u];
		}
		FL=0;
		rep(i,0,B){
			g[u][i]=min(g[u][i],dp[u][0]);
		}
		// printf("%d %d %d\n",u,dp[u][0],dp[u][1]);
	}
	void solve(){
		mems(g,0x3f),mems(mn,0x3f);
		dfs1(rt);
		printf("%d\n",dp[rt][0]);
	}
}
void Yorushika(){
	read(n,rt,A,B);
	if(A<=B){
		puts("1");
		return;
	}
	rep(i,1,n-1){
		int u,v;read(u,v);
		add(u,v),add(v,u);
	}
	if(n<=3000){
		s1::solve();
	}else{
		
	}
}
signed main(){
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	int t=1;
	//read(t);
	while(t--){
		Yorushika();
	}
}